package com.dch.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dch.system.entity.SysResources;
import com.dch.system.mapper.SysResourcesMapper;
import com.dch.system.service.SysResourcesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mayl
 * @since 2020-10-29
 */
@Service
public class SysResourcesServiceImpl extends ServiceImpl<SysResourcesMapper, SysResources> implements SysResourcesService {


    @Override
    public List<SysResources> listByUserId(Integer userId) {
        QueryWrapper<SysResources> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().inSql(SysResources::getId, "SELECT role_id from sys_role_resources  where role_id in (select role_id from sys_user_role where user_id = "+userId+") GROUP BY role_id");
        return this.baseMapper.selectList(queryWrapper);
    }
}
